package com.atguigu.yygh.hosp.controller;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.service.HospitalService;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.param.hosp.hospStatusParam;
import com.atguigu.yygh.param.page.HospPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author WGH
 */
@Api(tags = "医院管理接口")
@RestController
@RequestMapping("/admin/hosp/hospital/")
public class HospitalController {

    @Resource
    private HospitalService hospitalService;

    /**
     * 医院列表--分页查询
     * @param page
     * @return
     */
    @ApiOperation(value = "获取分页列表")
    @PostMapping(value = "/getPage")
    public Result index(@RequestBody HospPage page) {
        Page<Hospital> pageModel=hospitalService.selectHospPage(page);
        return new Result(pageModel);
    }

    /**
     * 更新医院上线状态
     * @param param
     * @return
     */
    @ApiOperation(value = "更新医院上线状态")
    @PostMapping("/lockHospitalSet")
    public Result lockHospitalSet(@RequestBody hospStatusParam param) {
        hospitalService.updateStatus(param);
        return new Result<>();
    }

    @ApiOperation(value = "获取医院详情")
    @GetMapping("/show")
    public Result show(@RequestParam String id) {
        return new Result(hospitalService.getHospByID(id));
    }

}
